<?php

namespace App\Admin\Actions\ShopOrder;

use App\Library\Logic\OperateLogLogic;
use App\Library\Models\AdminShopOrderModel;
use Encore\Admin\Actions\Response;
use Encore\Admin\Actions\RowAction;
use Encore\Admin\Facades\Admin;

class ShopOrderSystemAction extends RowAction
{
    public $name = '系统订单';

    /**
     * handle
     * @param AdminShopOrderModel $model
     * @return Response
     */
    public function handle(AdminShopOrderModel $model): Response
    {
        $model->ext->system_at = now();
        $model->ext->save();
        OperateLogLogic::add(Admin::user()->user_id, 'admin.shopOrder.system');
        return $this->response()->success('操作成功')->refresh();
    }

    /**
     * dialog
     * @return void
     */
    public function dialog(): void
    {
        $this->confirm('确定设置吗?');
    }
}
